package com.example.demo.controller;

import com.example.demo.scheduledtask.WmsPurchaseCallback;
import com.example.demo.vo.DeletePurchaseReceiptFormCallbackReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : Zhang.yt
 * @date : 2023/12/11
 */
@Api(tags = "仓库回写API")
@RestController
@RequestMapping("/wms")
public class WmsController {

    @Resource
    private WmsPurchaseCallback wmsPurchaseCallback;

//    /**
//     * 采购收货回调
//     * @return
//     */
//    @PostMapping("/purchaseReceiptCallback")
//    public String purchaseReceiptCallback(){
//        wmsPurchaseCallback.purchaseReceiptCallback();
//        return "成功！";
//    }
//
//    /**
//     * 删除采购收货回调 PMDN001
//     * @return
//     */
//    @PostMapping("/deletePurchaseReceiptCallback")
//    public String deletePurchaseReceiptCallback(@RequestParam("orderNo") String orderNo){
//        wmsPurchaseCallback.deletePurchaseReceiptCallback(orderNo);
//        return "成功！";
//    }

        /**
     * 采购收货回调
     * @return
     */
    @PostMapping("/purchaseReceiptCallbackByIncomingInspection")
    @ApiOperation(value = "采购收货回调")
    public String purchaseReceiptCallbackByIncomingInspection(){
        wmsPurchaseCallback.purchaseReceiptCallbackByIncomingInspection();
        return "成功！";
    }

    /**
     * 删除采购收货回调 PMDN001
     * @return
     */
    @ApiOperation(value = "删除采购收货回调")
    @GetMapping("/deletePurchaseReceiptCallbackByIncomingInspection")
    public String deletePurchaseReceiptCallbackByIncomingInspection(@RequestParam("orderNo") String orderNo,@RequestParam("flg") boolean flg){
        String incomingInspection = wmsPurchaseCallback.deletePurchaseReceiptCallbackIncomingInspection(orderNo, flg);
        return incomingInspection;
    }


    @ApiOperation(value = "删除采购收货回调(新)")
    @GetMapping("/checkmaterialRollback")
    public String checkmaterialRollback(){
        String incomingInspection = wmsPurchaseCallback.checkmaterialRollback();
        return incomingInspection;
    }

    /**
     * 删除采购收货回调 PMDN001 --指定单号
     * @return
     */
    @ApiOperation(value = "删除采购收货回调--指定erp单号")
    @PostMapping("/deletePurchaseReceiptCallbackByIncomingInspectionByNo")
    public String deletePurchaseReceiptCallbackByIncomingInspectionByNo(@RequestParam("orderNo") String orderNo,@RequestParam("erpNo") String erpNo){
        wmsPurchaseCallback.deletePurchaseReceiptCallbackByIncomingInspectionByNo(orderNo,erpNo);
        return "成功！";
    }

    /**
     * 删除采购收货回调 PMDN001  特采
     * @return
     */
    @ApiOperation(value = "删除采购收货回调--特采")
    @PostMapping("/deletePurchaseReceiptCallbackByIncomingInspectionTc")
    public String deletePurchaseReceiptCallbackByIncomingInspectionTc(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deletePurchaseReceiptCallbackByIncomingInspectionTc(orderNo);
        return "成功！";
    }

//    /**
//     * 采购入库单回调
//     * @return
//     */
//    @PostMapping("/purchaseReceiptFormCallback")
//    public String purchaseReceiptForm(){
//        wmsPurchaseCallback.purchaseReceiptFormCallback();
//        return "成功！";
//    }


    /**
     * 采购入库单回调（货架位绑定）
     * @return
     */
    @ApiOperation(value = "采购入库单回调（货架位绑定）")
    @PostMapping("/purchaseReceiptFormCallbackByRackBinding")
    public String purchaseReceiptForm(){
        wmsPurchaseCallback.purchaseReceiptFormCallbackByRackBinding();
        return "成功！";
    }

//    /**
//     * 删除采购入库单回调，采购入库会写后自动过账，不能删除
//     * @return
//     */
    @PostMapping("/deletePurchaseReceiptFormCallback")
    public String deletePurchaseReceiptFormCallback(@RequestBody DeletePurchaseReceiptFormCallbackReq receiptFormCallbackReq){
        wmsPurchaseCallback.deletePurchaseReceiptFormCallback(receiptFormCallbackReq);
        return "成功！";
    }


    /**
     * 仓间调拨单回调
     * @return
     */
    @PostMapping("/warehouseTransferCallback")
    public String warehouseTransferCallback(){
        wmsPurchaseCallback.warehouseTransferCallback();
        return "成功！";
    }

    /**
     * 仓间调拨单回调（删除）
     */
    @PostMapping("/deleteWarehouseTransferCallback")
    public String deleteWarehouseTransferCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deleteWarehouseTransferCallback(orderNo);
        return "成功！";
    }

    /**
     * 二阶段调拨拨出单回调
     * @return
     */
//    @PostMapping("/transferOutOutCallback")
//    public String transferOutCallback(){
//        wmsPurchaseCallback.transferOutCallback();
//        return "成功！";
//    }

    /**
     * 二阶段调拨拨入过账单回调
     * @return
     */
    @PostMapping("/transferInCallback")
    public String transferInCallback(){
        wmsPurchaseCallback.transferInCallback();
        return "成功！";
    }

    /**
     * 删除二阶段调拨拨出单回调
     * @return
     */
    @PostMapping("/deleteTransferOutOutCallback")
    public String deleteTransferOutOutCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deleteTransferOutOutCallback(orderNo);
        return "成功！";
    }

    /**
     * 删除二阶段调拨拨入单回调
     * @return
     */
    @PostMapping("/deleteTransferInCallback")
    public String deleteTransferInCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deleteTransferInCallback(orderNo);
        return "成功！";
    }

    /**
     * 生产工单（领料单）
     */
    @PostMapping("/pickingOutCallback")
    public String pickingOutCallback() {
        wmsPurchaseCallback.pickingOutCallback();
        return "成功！";
    }

    /**
     * 刪除生产工单（领料单）
     */
    @PostMapping("/deletePickingOutCallback")
    public String deletePickingOutCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deletePickingOutCallback(orderNo);
        return "成功！";
    }

    /**
     * 生产工单（退料单）
     */
    @PostMapping("/returnInCallback")
    public String returnInCallback() {
        wmsPurchaseCallback.returnInCallback();
        return "成功！";
    }

    /**
     * 刪除生产工单（退料单）
     */
    @PostMapping("/deleteReturnInCallback")
    public String deleteReturnInCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deleteReturnInCallback(orderNo);
        return "成功！";
    }

    /**
     * 其他入库 杂项入库
     */
//    @PostMapping("/otherInWarehousingCallback")
//    public String otherInWarehousingCallback() {
//        wmsPurchaseCallback.otherInWarehousingCallback();
//        return "成功！";
//    }

//    /**
//     * 其他出库 杂项出库
//     */
//    @PostMapping("/otherOutWarehouseCallback")
//    public String otherOutWarehouseCallback() {
//        wmsPurchaseCallback.otherOutWarehouseCallback();
//        return "成功！";
//    }
    /**
     * 刪除其他出库
     */
    @PostMapping("/deleteOtherOutWarehouseCallback")
    public String deleteOtherOutWarehouseCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deleteOtherOutWarehouseCallback(orderNo);
        return "成功！";
    }
    /**
     * 刪除其他入库
     */
    @PostMapping("/deleteOtherInWarehousingCallback")
    public String deleteOtherInWarehousingCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deleteOtherInWarehousingCallback(orderNo);
        return "成功！";
    }

    /**
     * 生产完工入库
     */
    @PostMapping("completeInCallback")
    public String completeInCallback() {
        wmsPurchaseCallback.completeInCallback();
        return "成功！";
    }


    /**
     * 删除完工入库反写ERP
     */
    @PostMapping("/deleteCompleteInCallback")
    public String deleteCompleteInCallback(@RequestParam("orderNo") String orderNo){
        wmsPurchaseCallback.deleteCompleteInCallback(orderNo);
        return "成功！";
    }

    /**
     * 销售出库回填
     */
    @PostMapping("/sellOutCallback")
    public String sellOutCallback() {
        wmsPurchaseCallback.sellOutCallback();
        return "成功！";
    }

    /**
     * 删除销售出库回填
     */
    @PostMapping("/deleteSellOutCallback")
    public String deleteSellOutCallback(@RequestParam("orderNo") String orderNo ) {
        wmsPurchaseCallback.deleteSellOutCallback(orderNo);
        return "成功！";
    }

    /**
     * 生产调拨单过账
     * @return
     */
    @PostMapping("/WarehouseTransferPost")
    public String WarehouseTransferPost() {
        wmsPurchaseCallback.WarehouseTransferPost();
        return "成功！";
    }

    /**
     * 其他（杂项）出库过账
     * @return
     */
    @PostMapping("/MiscellaneousPost")
    public String MiscellaneousPost() {
        wmsPurchaseCallback.MiscellaneousPost();
        return "成功！";
    }

    /**
     * 其他（杂项）入库过账
     * @return
     */
    @PostMapping("/MiscellaneousPostIn")
    public String MiscellaneousPostIn() {
        wmsPurchaseCallback.MiscellaneousPostIn();
        return "成功！";
    }

    /**
     * 其他（杂项）出入库过账还原
     * @return
     */
    @PostMapping("/deleteMiscellaneousPost")
    @ApiOperation("其他（杂项）出入库过账还原")
    public String deleteMiscellaneousPost() {
        wmsPurchaseCallback.deleteMiscellaneousPost();
        return "成功！";
    }

    /**
     * 二阶调拨拨出过账
     * @return
     */
    @PostMapping("/TransferOutPost")
    @ApiOperation("二阶调拨拨出过账")
    public String TransferOutPost() {
        wmsPurchaseCallback.TransferOutPost();
        return "成功！";
    }

    /**
     * 销售退货
     * @return
     */
    @PostMapping("/SalesReturns")
    @ApiOperation("销售退货")
    public String SalesReturns() {
        wmsPurchaseCallback.SalesReturns();
        return "成功！";
    }

    /**
     * 成品冻结
     * @return
     */
    @PostMapping("/CodeHoldcnt")
    @ApiOperation("成品冻结")
    public String CodeHoldcnt() {
        wmsPurchaseCallback.CodeHoldcnt();
        return "成功！";
    }

    /**
     * 采购仓退
     * @return
     */
    @PostMapping("/PurchaseBackPost")
    @ApiOperation("采购退货")
    public String PurchaseBackPost() {
        wmsPurchaseCallback.PurchaseBackPost();
        return "成功！";
    }
}
